﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using myMVCdb.Models;

namespace myMVCdb.Data
{
    public class myMVCdbInitilizer:DropCreateDatabaseAlways<myMVCdbContext>
    {
        protected override void Seed(myMVCdbContext db)
        {
            db.Users.Add(new Models.Users
            {
                UserName="Joker",
                PassWord="123",
                CreateAt =DateTime.Now,
                UpdateAt= DateTime.Now,
                Version=0
            });
            db.Messages.AddRange(new List<Messages>
            {
                new Messages{
                    FromUserId=1,
                    Content="第一次写MVC",
                    CreateAt=DateTime.Now,
                    UpdateAt=DateTime.Now,
                    Version=0
                }
            });
            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    MsgId=1,
                    FromUserId=1,
                    Content="蒹葭",
                    CreateAt=DateTime.Now,
                    UpdateAt=DateTime.Now,
                    Version=0
                }
            });
            db.SaveChanges();

            base.Seed(db);
        }
    }
}